import java.util.LinkedList;
import java.util.Queue;

class MyCircularQueue {
    public  int[] elme ;
    public int front ;
    public  int rear ;
    public int size;
    public MyCircularQueue(int k) {
        size=k+1;
        elme=new int[k+1];
        front=0;
        rear=0;
    }

    public boolean enQueue(int value) {
        if(isFull()){
            return false;
        }else{
            elme[rear]=value;
            rear=(rear+1)%size;
            return true;
        }
    }

    public boolean deQueue() {
        if (isEmpty()){
            return false;
        }
        front=(front+1)%size;
        return true;
    }

    public int Front() {
        if (isEmpty()){
            return -1;
        }
        return elme[front];
    }

    public int Rear() {
        if (isEmpty()){
            return -1;
        }
        if(rear==0){
            int x=size-1;
            return elme[x];
        }else{
            return elme[rear-1];
        }

    }

    public boolean isEmpty() {

        return front==rear;

    }

    public boolean isFull() {

        return (rear+1)%size==front;
    }
}

/**
 * Your MyCircularQueue object will be instantiated and called as such:
 * MyCircularQueue obj = new MyCircularQueue(k);
 * boolean param_1 = obj.enQueue(value);
 * boolean param_2 = obj.deQueue();
 * int param_3 = obj.Front();
 * int param_4 = obj.Rear();
 * boolean param_5 = obj.isEmpty();
 * boolean param_6 = obj.isFull();
 */